<?php
/**
 *  NevuxBB - Free Forum Software
 *  Copyright (C) 2008, 2010 NevuxBB (No one specific author)*  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * URL Class
 * File: url_class.php
 * Purpose: Generating file paths
 * Todo: improve the handling of the paths
 *
 */

class urlSystem extends mod_rewrite {
	
	/**
	* Used to build URL's
	*
	* @param string $id
	* @param string $data
	* @return string
	* @access public
	*/	
	public function viewURL($id, $data = NULL) {
		if(self::isOn()) {
			// modrewrite is on
			switch($id) {
				case 1:
					// view forum
					if(isset($data['page_id'])) { $end_data = ',page-' . $data['page_id']; }
					return 'viewforum-' . $data['forum_id'] . $end_data . '.html';
					break;
				case 2:
					// view profile
					return 'member-' . $data['user_id'] . ',' . $data['user_name'] . '.html';
					break;
				case 3:
					// view topic
					if(isset($data['page_id'])) { $end_data = ',page-' . $data['page_id']; }
					return 'topic-' . $data['topic_id'] . $end_data . '.html';
					break;
				case 4:
					// view membrlist
					if($data['perform'] !== true) {
						// require no organisation, perform standard sorting
						return 'memberlist.html';
					} else {
						// user has selected some custom organisation
						return 'memberlist,x' . $data['actions']['x'] . ',y' . $data['actions']['y'] . ',ord' . $data['actions']['order'] . '.html';
					}
					break;
			}
		} else {
			// standard URLs
			switch($id) {
				case 1:
					// view forum
					if(isset($data['page_id'])) { $end_data = '&page=' . $data['page_id']; }
					return 'viewforum.php?id=' . $data['forum_id'] . $end_data;
					break;
				case 2:
					// view profile
					return 'viewprofile.php?id=' . $data['user_id'];
					break;
				case 3:
					// view topic
					if(isset($data['page_id'])) { $end_data = '&page=' . $data['page_id']; }
					return 'viewtopic.php?id=' . $data['topic_id'] . $end_data;
					break;
				case 4:
					// view memberlist
					return 'memberlist.php';
					break;
			}
		}
	}
	
	/**
	* Used to get navigational URL's
	*
	* @param string $type
	* @return string
	* @access public
	*/	
	public function navParts($type) {
		if(self::isOn()) {
			// modrewrite is on
			switch($type) {
				case 1:
					// board index
					return '/';
					break;
				case 2:
					// search page
					return 'search.html';
					break;
				case 3:
					// rules
					return 'misc,rules.html';
					break;
				case 4:
					// logout page
					return 'logout.html';
					break;
				case 5:
					// registration page
					return 'register.html';
					break;
				case 6:
					// login page
					return 'login.html';
					break;
				case 7:
					// lostpassword page
					return 'login.html-lpass';
					break;
				case 8:
					// rules
					return 'misc,faq.html';
					break;
				case 9:
					// login page
					return 'calendar.html';
					break;
				
			}
		} else {
			// standard URLs
			switch($type) {
				case 1:
					// board index
					return 'index.php';
					break;
				case 2:
					// search page
					return 'search.php';
					break;
				case 3:
					// rules
					return 'misc.php?act=rules';
					break;
				case 4:
					// logout page
					return 'logout.php';
					break;
				case 5:
					// registration page
					return 'register.php';
					break;
				case 6:
					// login page
					return 'login.php';
					break;
				case 7:
					// lostpass page
					return 'login.php?act=lpass';
					break;
				case 8:
					// rules
					return 'misc.php?act=faq';
					break;
				case 9:
					// rules
					return 'calendar.php';
					break;
			}
		}
	}
}

?>